import Koa from 'koa'
import views from 'koa-views'
import serve from 'koa-static'
import appConf from './confs/app'
import {router} from './routes'

/**
 * 应用
 */
const app = new Koa

/**
 * 静态服务器
 */
app.use(serve(__dirname + '/public'))

/**
 * 设置模板引擎
 * 及后缀
 */
app.use(views(__dirname + '/views', {
    html: 'ejs',
    extension: 'html'
}))

/**
 * 路由
 */
app
    .use(router.routes())
    .use(router.allowedMethods())

/**
 * 开启服务
 */
app.listen(appConf.port, () => {
    console.log('============================================')
    console.log('服务器启动成功')
    console.log('============================================')
})